package com.agan.aganjavaspyder.crawler.ct_test;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.Href;
import com.geccocrawler.gecco.annotation.HtmlField;
import com.geccocrawler.gecco.spider.JsonBean;
import lombok.Data;

/**
 * @author agan
 * @ClassName Category
 * @Description
 * @Date 2020/10/14 4:50 下午
 **/
@Gecco(matchUrl = "http://www.189.cn/", pipelines = "consolePipeline")
@Data
public class BjCategory2 implements JsonBean {


    @Href
    @HtmlField(cssPath = "#index > nav > li:nth-child(2) > a)")
    private String href;
/*    *//**
     * 点击 特惠购机
     *//*
    @Href
    @HtmlField(cssPath = "#J_cateUl > li:nth-child(6)")
    private String href;*/

    public static void main(String[] args) {


        GeccoEngine.create()
                //Gecco搜索的包路径
                .classpath("com.agan.aganjavaspyder.crawler")
                //开始抓取的页面地址
                .seed("http://www.189.cn/")
                //.seed("http://z.bj.189.cn/index/category.html")
                //开启几个爬虫线程
                .thread(1)
                //单个爬虫每次抓取完一个请求后的间隔时间
                .interval(2000)
                .start();
    }
}
